﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using GovernmentOfficeProject.SysTools;
using System.Collections;

namespace GovernmentOfficeProject.LevelDataAccessModel
{
    public class Entity_USER_Department
    {
        private decimal deptID = -1;                          //部门唯一编号.
        public decimal DeptID
        {     
            get { return deptID; }
            set { deptID = value; }
        }

        
        private List<Entity_USER_User> users;            //一个部门下有多个用户，一个用户可以有多个部门，多对多关系。
        public List<Entity_USER_User> Users
        {
            get
            { return users; }
            
            set
            {
                AppLog.Write("Entity_User_Department.users---------------set", AppLog.LogMessageType.Debug);
                users = value; 
            }
        }


        private string deptName;                        //部门名称.
        public string DeptName
        {
            get { return deptName; }
            set { deptName = value; }
        }

        private string deptDesc;                        //部门描述.
        public string DeptDesc
        {
            get { return deptDesc; }
            set { deptDesc = value; }
        }

        //private Entity_USER_Department deptParent;  //上级部门以将实体类型改为ID引用,以方便程序编写.
        //public Entity_USER_Department DeptParent
        //{
        //    get { return deptParent; }
        //    set 
        //    {
        //        deptParent = value;
        //    }
        //}

        private decimal deptParentID = -1;
        public decimal DeptParentID
        {
            get { return deptParentID; }
            set { deptParentID = value; }
        }

        private decimal createUserID = -1;                   //谁创建的当前资料
        public decimal CreateUserID
        {
            get { return createUserID; }
            set { createUserID = value; }
        }


        private string createDateTime;                  //创建时间是何时
        public string CreateDateTime
        {
            get { return createDateTime; }
            set
            {
                createDateTime = value;
            }
        }

        private decimal modifyUserID = -1;                   //谁修改的当前资料
        public decimal ModifyUserID
        {
            get { return modifyUserID; }
            set { modifyUserID = value; }
        }

        private string modifyDateTime;                //修改时间
        public string ModifyDateTime
        {
            get { return modifyDateTime; }
            set
            {
                modifyDateTime = value;
            }
        }

        private decimal recordStatus = -1;                    //记录部门状态
        public decimal RecordStatus
        {
            get { return recordStatus; }
            set { recordStatus = value; }
        }

        private bool selected = false;          //用户控件的选中状态.

        public bool Selected
        {
            get { return selected; }
            set { selected = value; }
        }

    }

    //用于删除重复值.
    public class Entity_USER_Department_Comparer : IEqualityComparer<Entity_USER_Department>
    {
        public bool Equals(Entity_USER_Department x, Entity_USER_Department y)
        {
            //分别对属性进行比较
            if (x.DeptID == y.DeptID && x.Users == y.Users && x.DeptName == y.DeptName && x.DeptParentID == y.DeptParentID && x.DeptDesc == y.DeptDesc && x.RecordStatus == y.RecordStatus && x.Selected == y.Selected && x.CreateUserID == y.CreateUserID && x.CreateDateTime == y.CreateDateTime && x.ModifyUserID == y.ModifyUserID && x.ModifyDateTime == y.ModifyDateTime)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public int GetHashCode(Entity_USER_Department obj)
        {
            return 0;
        }
    }
}
